package com.example.myapplication.apter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.myapplication.R;
import com.example.myapplication.ShuJu.DroutedetailsBean;
import com.example.myapplication.urbansubway.UrbansubwayActivity;

import java.util.List;

public class SubwayroutesApter extends RecyclerView.Adapter<SubwayroutesApter.MyHolder>{
    private Context context;
    private String TAG = "TAG";
    private String name ;
    private List<DroutedetailsBean.DataDTO.MetroStepListDTO> list;


    public SubwayroutesApter(Context context, List<DroutedetailsBean.DataDTO.MetroStepListDTO> list,String name) {
        this.context = context;
        this.list = list;
        this.name = name;
    }





    @NonNull
    @Override
    public SubwayroutesApter.MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_subwayroutes,null);
        return new SubwayroutesApter.MyHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull SubwayroutesApter.MyHolder holder, int position) {
        if(list==null ||  name ==null){
            return;
        }

        if(name.equals(list.get(position).getName())){
            holder.name.setText(list.get(position).getName());
            holder.name.setTextColor(Color.RED);
        }else {
            holder.name.setText(list.get(position).getName());
            holder.name.setTextColor(Color.GRAY);
        }


    }

    @Override
    public int getItemCount() {
        return list == null ? 0 : list.size();
    }

    class MyHolder extends RecyclerView.ViewHolder {
        private final TextView name;


        public MyHolder(@NonNull View itemView) {
            super(itemView);
            name = itemView.findViewById(R.id.name);
        }
    }
}







